mod game;
mod tank;
mod ai;
mod map;
mod projectile;

use ggez::{Context, ContextBuilder, GameResult};
use ggez::event::{self, EventHandler};
use std::env;
use std::path;

use crate::game::Game;

fn main() -> GameResult {
    // 创建上下文和事件循环
    let resource_dir = if let Ok(manifest_dir) = env::var("CARGO_MANIFEST_DIR") {
        let mut path = path::PathBuf::from(manifest_dir);
        path.push("resources");
        path
    } else {
        path::PathBuf::from("./resources")
    };

    let (mut ctx, event_loop) = ContextBuilder::new("tank_battle", "Tank Developer")
        .add_resource_path(resource_dir)
        .build()?;

    let game = Game::new(&mut ctx)?;
    
    // 运行游戏事件循环
    event::run(ctx, event_loop, game)
}